package com.zb.oauth.controller;

import com.zb.oauth.service.MyAuthService;
import com.zb.oauth.util.AuthToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/myauth")
public class MyAuthController {

    @Autowired
    private MyAuthService myAuthService;

    @Value("${auth.clientId}")
    private String clientId;
    @Value("${auth.clientSecret}")
    private String clientSecret;

    @PostMapping("/login")
    public AuthToken login(@RequestParam("username") String username, @RequestParam("passwd") String passwd){
        System.out.println(clientId+"----------------"+clientSecret);
        return myAuthService.login(username,passwd,clientId,clientSecret);
    }

}
